package limeirafol.gui.Cadastro;

import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.SwingConstants;
import limeirafol.Global;
import limeirafol.bean.BeanCadastro;
import limeirafol.remote.cadastro.BanhoVO;
import limeirafol.remote.cadastro.ProdutoVO;
import limeirafol.remote.cadastro.ProdutoItemVO;
import limeirafol.remote.cadastro.Situacao;
import limeirafol.remote.cadastro.TipoProduto;
import limeirafol.remote.cadastro.tipoEmbalagem;
import org.openide.util.Exceptions;
import lbframework.bean.internalFrame.LBInternalFrame;
import lbframework.bean.mdiFrame.LBMdiFrame;
import lbframework.bean.table.LBColumnTable;
import lbframework.classe.Util;
import lbframework.classe.LBException;
import limeirafol.gui.administracao.AdministracaoPrecoGUI;

public class ProdutoCadastroGUI extends LBInternalFrame {

    public ProdutoVO oProdutoCadastro = new ProdutoVO();
    BeanCadastro beanCadastro = new BeanCadastro();
    public BanhoVO oBanho = new BanhoVO();
    public double valorBanhoMl = 0;
    public double precoTotal = 0;
    public double pesoFinal = 0;
    public double valorTotalBanho = 0;
    public double custoTotal = 0;
    public boolean isBrinco = false;
    String caminhoArquivo = "";

    public ProdutoCadastroGUI(LBMdiFrame i_mdiFrame) throws Exception {
        super(i_mdiFrame);
        initComponents();
        centralizarForm();

        cboTipoBanho.setTabela("banho");
        cboTipoBanho.setCampoOrdenacao("id", "");
        cboTipoBanho.carregar();


        cboTipoProduto.setTabela("tipoproduto");
        cboTipoProduto.carregar();

        cboSituacao.setTabela("situacaocadastro");
        cboSituacao.carregar();

        if (cboSituacao.getId() == Situacao.ATIVO.getId()) {
            cboSituacao.setEnabled(false);
        }

        lblFoto.setIcon(new ImageIcon("/LimeiraFol/Imagens/Produtos/sem_foto.jpg"));
        txtFoto.setText("SEM_FOTO.JPG");
        btnZoom.setVisible(false);

        txtValorOuro.setDouble(Global.getParametro(5).getDouble());

    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        vRToolBarPadrao1 = new lbframework.bean.toolBarPadrao.LBToolBarPadrao(this);
        vRPanel1 = new lbframework.bean.panel.LBPanel();
        vRLabel1 = new lbframework.bean.label.LBLabel();
        txtCodigo = new lbframework.bean.textField.LBTextField();
        vRLabel2 = new lbframework.bean.label.LBLabel();
        txtCodigoInterno = new lbframework.bean.textField.LBTextField();
        vRLabel3 = new lbframework.bean.label.LBLabel();
        txtDescricao = new lbframework.bean.textField.LBTextField();
        vRLabel4 = new lbframework.bean.label.LBLabel();
        cboTipoProduto = new lbframework.bean.comboBox.LBComboBox();
        vRLabel5 = new lbframework.bean.label.LBLabel();
        cboTipoBanho = new lbframework.bean.comboBox.LBComboBox();
        txtFoto = new lbframework.bean.textField.LBTextField();
        vRButton6 = new lbframework.bean.button.LBButton();
        vRLabel11 = new lbframework.bean.label.LBLabel();
        lblFoto =  new javax.swing.JLabel(new ImageIcon())
        {
            @Override
            public void paintComponent(java.awt.Graphics g) {
                super.paintComponent(g);
                g.drawImage(((ImageIcon)getIcon()).getImage(), 0, 0, getWidth(),                                                       getHeight(), null);
            }
        };
        btnZoom = new lbframework.bean.button.LBButton();
        cboSituacao = new lbframework.bean.comboBox.LBComboBox();
        vRLabel9 = new lbframework.bean.label.LBLabel();
        vRPanel2 = new lbframework.bean.panel.LBPanel();
        tblAcessorios = new lbframework.bean.tableEx.LBTableEx();
        vRButton1 = new lbframework.bean.button.LBButton();
        vRButton2 = new lbframework.bean.button.LBButton();
        vRButton3 = new lbframework.bean.button.LBButton();
        vRPanel3 = new lbframework.bean.panel.LBPanel();
        lblPeso = new lbframework.bean.label.LBLabel();
        txtPesoTotal = new lbframework.bean.textField.LBTextField();
        txtCustoTotal = new lbframework.bean.textField.LBTextField();
        vRLabel7 = new lbframework.bean.label.LBLabel();
        vRLabel8 = new lbframework.bean.label.LBLabel();
        txtValorBanho = new lbframework.bean.textField.LBTextField();
        txtValorFinal = new lbframework.bean.textField.LBTextField();
        lblValorFinal = new lbframework.bean.label.LBLabel();
        vRLabel10 = new lbframework.bean.label.LBLabel();
        txtValorOuro = new lbframework.bean.textField.LBTextField();
        vRPanel5 = new lbframework.bean.panel.LBPanel();
        vRButton4 = new lbframework.bean.button.LBButton();
        vRButton5 = new lbframework.bean.button.LBButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Cadastro de Produtos");
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosing(evt);
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        vRToolBarPadrao1.setRollover(true);
        vRToolBarPadrao1.setVisibleIncluir(true);
        vRToolBarPadrao1.setVisibleSalvar(true);

        vRLabel1.setText("Código");

        txtCodigo.setEnabled(false);

        vRLabel2.setText("Código Interno");

        txtCodigoInterno.setColumns(10);
        txtCodigoInterno.setObrigatorio(true);

        vRLabel3.setText("Descricao");

        txtDescricao.setColumns(40);
        txtDescricao.setObrigatorio(true);

        vRLabel4.setText("Tipo Produto");

        cboTipoProduto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboTipoProdutoActionPerformed(evt);
            }
        });

        vRLabel5.setText("Banho");

        txtFoto.setColumns(100);
        txtFoto.setEnabled(false);

        vRButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/bean/fileChooser/abrir.png"))); // NOI18N
        vRButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton6ActionPerformed(evt);
            }
        });

        vRLabel11.setText("Foto");

        lblFoto.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        btnZoom.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/zoomin.png"))); // NOI18N
        btnZoom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnZoomActionPerformed(evt);
            }
        });

        vRLabel9.setText("Situação");

        javax.swing.GroupLayout vRPanel1Layout = new javax.swing.GroupLayout(vRPanel1);
        vRPanel1.setLayout(vRPanel1Layout);
        vRPanel1Layout.setHorizontalGroup(
            vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(vRLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtCodigoInterno, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(vRLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(vRLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 386, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(vRLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cboTipoBanho, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(vRLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cboTipoProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(vRPanel1Layout.createSequentialGroup()
                                .addComponent(txtFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(vRButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(vRLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(vRLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnZoom, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        vRPanel1Layout.setVerticalGroup(
            vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, vRPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addComponent(vRLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addComponent(lblFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnZoom, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(vRLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(vRLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(vRLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtCodigoInterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(vRPanel1Layout.createSequentialGroup()
                                .addComponent(vRLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cboTipoBanho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(vRPanel1Layout.createSequentialGroup()
                                .addComponent(vRLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cboTipoProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(vRButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(vRPanel1Layout.createSequentialGroup()
                                .addComponent(vRLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtFoto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap())
        );

        vRPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Acessórios"));

        tblAcessorios.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblAcessoriosMouseClicked(evt);
            }
        });
        tblAcessorios.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tblAcessoriosKeyPressed(evt);
            }
        });

        vRButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/adicionar.png"))); // NOI18N
        vRButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton1ActionPerformed(evt);
            }
        });

        vRButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/remover.png"))); // NOI18N
        vRButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton2ActionPerformed(evt);
            }
        });

        vRButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/limpar.png"))); // NOI18N
        vRButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout vRPanel2Layout = new javax.swing.GroupLayout(vRPanel2);
        vRPanel2.setLayout(vRPanel2Layout);
        vRPanel2Layout.setHorizontalGroup(
            vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tblAcessorios, javax.swing.GroupLayout.DEFAULT_SIZE, 787, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, vRPanel2Layout.createSequentialGroup()
                        .addComponent(vRButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(vRButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(vRButton3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        vRPanel2Layout.setVerticalGroup(
            vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel2Layout.createSequentialGroup()
                .addComponent(tblAcessorios, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(vRButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(vRButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(vRButton3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        lblPeso.setText("Peso Total (g)");

        txtPesoTotal.setEnabled(false);
        txtPesoTotal.setMascara("Decimal 1");

        txtCustoTotal.setEnabled(false);
        txtCustoTotal.setMascara("Decimal 2");

        vRLabel7.setText("Preço do Bruto");

        vRLabel8.setText("Preço Banho");

        txtValorBanho.setEnabled(false);
        txtValorBanho.setMascara("Decimal 2");

        txtValorFinal.setEnabled(false);
        txtValorFinal.setMascara("Decimal 2");

        lblValorFinal.setText("Valor Custo Final");

        vRLabel10.setText("Valor Ouro");

        txtValorOuro.setEnabled(false);
        txtValorOuro.setMascara("Decimal 2");

        javax.swing.GroupLayout vRPanel3Layout = new javax.swing.GroupLayout(vRPanel3);
        vRPanel3.setLayout(vRPanel3Layout);
        vRPanel3Layout.setHorizontalGroup(
            vRPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel3Layout.createSequentialGroup()
                .addGroup(vRPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtPesoTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPeso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(vRPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtCustoTotal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(vRLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(vRPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtValorBanho, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(vRLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(vRPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtValorOuro, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(vRLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(vRPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtValorFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblValorFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(407, Short.MAX_VALUE))
        );

        vRPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {txtCustoTotal, txtPesoTotal, txtValorBanho, txtValorFinal});

        vRPanel3Layout.setVerticalGroup(
            vRPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel3Layout.createSequentialGroup()
                .addComponent(vRLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtValorOuro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(vRPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(vRPanel3Layout.createSequentialGroup()
                    .addComponent(lblValorFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(txtValorFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(vRPanel3Layout.createSequentialGroup()
                    .addComponent(vRLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(txtValorBanho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(vRPanel3Layout.createSequentialGroup()
                    .addComponent(vRLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(txtCustoTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(vRPanel3Layout.createSequentialGroup()
                    .addComponent(lblPeso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(txtPesoTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        vRButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/sair.png"))); // NOI18N
        vRButton4.setText("Sair");
        vRButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton4ActionPerformed(evt);
            }
        });

        vRButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/salvar.png"))); // NOI18N
        vRButton5.setText("Salvar");
        vRButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton5ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout vRPanel5Layout = new javax.swing.GroupLayout(vRPanel5);
        vRPanel5.setLayout(vRPanel5Layout);
        vRPanel5Layout.setHorizontalGroup(
            vRPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, vRPanel5Layout.createSequentialGroup()
                .addContainerGap(633, Short.MAX_VALUE)
                .addComponent(vRButton5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(vRButton4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        vRPanel5Layout.setVerticalGroup(
            vRPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(vRButton4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(vRButton5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(vRPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(vRPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(vRPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(vRPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(vRToolBarPadrao1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(vRToolBarPadrao1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(vRPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(vRPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(vRPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(vRPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(19, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    @Override
    public void incluir() throws Exception {
        verificarAlteracaoTela();

        txtCodigoInterno.setText("");
        txtCodigo.setText("");
        txtCustoTotal.setText("");
        txtDescricao.setText("");
        txtPesoTotal.setText("");
        txtValorBanho.setText("");
        txtValorFinal.setText("");

        oProdutoCadastro.vItem = new Vector();
        exibirAcessorio();

        txtCodigoInterno.requestFocusLater();

        getEstadoTelaInicial();

    }

    public void exibirAcessorio() throws Exception {
        double pesoTotalProduto = 0;
        double precoTotalCusto = 0;
        double pesoML = 0;
        double pesoKg = 0;
        double valorBanhoKg = 0;

        LBColumnTable[] colunas = new LBColumnTable[]{
            new LBColumnTable("Acessorio", 70, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Descrição", 280, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Quantidade", 80, true, SwingConstants.RIGHT, false, null),
            new LBColumnTable("Tipo Banho", 70, true, SwingConstants.RIGHT, false, null),
            new LBColumnTable("Custo Unitário", 80, true, SwingConstants.RIGHT, false, null),
            new LBColumnTable("Peso Unitáro", 80, true, SwingConstants.RIGHT, false, null),
            new LBColumnTable("Peso Total", 80, true, SwingConstants.RIGHT, false, null),
            new LBColumnTable("Custo Total", 80, true, SwingConstants.RIGHT, false, null)
        };
        Object[][] dados = new Object[oProdutoCadastro.vItem.size()][colunas.length];

        int i = 0;

        for (ProdutoItemVO oItem : oProdutoCadastro.vItem) {
            dados[i][0] = Util.formatNumber(oItem.idAcessorio, 6);
            dados[i][1] = oItem.acessorio;
            if (oItem.idTipoEmbalagem == tipoEmbalagem.KG.getId()) {
                dados[i][2] = Util.formatDecimal3(oItem.quantidade);
            } else {
                dados[i][2] = Util.formatDecimal0(oItem.quantidade);
            }
            dados[i][3] = oItem.tipoBanho;
            dados[i][4] = Util.formatDecimal3(oItem.custoUnitario);
            dados[i][5] = Util.formatDecimal1(oItem.pesoUnitario) + " g";
            dados[i][6] = Util.formatDecimal1(oItem.pesoTotal) + " g";
            dados[i][7] = Util.formatDecimal3(oItem.custoTotal);

            i++;

            pesoTotalProduto += oItem.pesoTotal;
            precoTotalCusto += oItem.custoTotal;

            oBanho = beanCadastro.consultaBanhoMl(oItem.idTipoBanho);

            if (oBanho.utilizamilesimos) {
                pesoML += oItem.pesoTotal;
            } else {
                pesoKg += oItem.pesoTotal;
                valorBanhoKg = (pesoKg * (oBanho.precoporkilo / 1000));
            }
        }

        tblAcessorios.setModel(dados, colunas);

        calculaValorBanhoMl(pesoML);
        custoTotal = precoTotalCusto;
        valorTotalBanho = valorBanhoMl + valorBanhoKg;
        precoTotal = valorTotalBanho + custoTotal;
        txtValorFinal.setDouble(precoTotal);
        pesoFinal = pesoTotalProduto;

        if (cboTipoProduto.getId() == TipoProduto.BRINCO.getId()) {
            txtValorFinal.setDouble(precoTotal * 2);
            txtPesoTotal.setDouble(pesoFinal * 2);
            txtValorBanho.setDouble(valorTotalBanho * 2);
            txtCustoTotal.setDouble(custoTotal * 2);
        } else {
            txtValorFinal.setDouble(precoTotal);
            txtPesoTotal.setDouble(pesoFinal);
            txtValorBanho.setDouble(valorTotalBanho);
            txtCustoTotal.setDouble(custoTotal);
        }
    }

    public void carregarProduto(int i_id) throws Exception {
        oProdutoCadastro = beanCadastro.carregarProduto(i_id);

        txtCodigo.setInt(oProdutoCadastro.id);
        txtCodigoInterno.setText(oProdutoCadastro.codigoInterno);
        txtDescricao.setText(oProdutoCadastro.descricao);
        cboTipoBanho.setId(oProdutoCadastro.idBanho);
        cboTipoProduto.setId(oProdutoCadastro.idTipoProduto);
        txtPesoTotal.setDouble(oProdutoCadastro.pesoTotal);
        txtCustoTotal.setDouble(oProdutoCadastro.precoDoBruto);
        txtValorBanho.setDouble(oProdutoCadastro.precoBanho);
        txtValorFinal.setDouble(oProdutoCadastro.precoFinal);
        txtFoto.setText(oProdutoCadastro.foto);

        if (!(txtFoto.getText().equals("SEM_FOTO.JPG"))) {
            lblFoto.setIcon(new ImageIcon("/LimeiraFol/Imagens/Produtos/" + oProdutoCadastro.foto));
            btnZoom.setVisible(true);
        } else {
            lblFoto.setIcon(new ImageIcon("/LimeiraFol/Imagens/Produtos/sem_foto.jpg"));
            txtFoto.setText("sem_foto.jpg");
            btnZoom.setVisible(false);
        }


        cboSituacao.setId(oProdutoCadastro.idSituacaoCadastro);
        if (cboSituacao.getId() == Situacao.EXCLUIDO.getId()) {
            cboSituacao.setEnabled(true);
        }

        exibirAcessorio();

        getEstadoTelaInicial();

    }

    @Override
    public void salvar() throws Exception {
        Util.validarCampoTela(this.getCampoObrigatorio());

        oProdutoCadastro.codigoInterno = txtCodigoInterno.getText();
        oProdutoCadastro.descricao = txtDescricao.getText();
        oProdutoCadastro.idBanho = cboTipoBanho.getId();
        oProdutoCadastro.idTipoProduto = cboTipoProduto.getId();
        oProdutoCadastro.pesoTotal = txtPesoTotal.getDouble();
        oProdutoCadastro.precoBanho = txtValorBanho.getDouble();
        oProdutoCadastro.precoDoBruto = txtCustoTotal.getDouble();
        oProdutoCadastro.precoFinal = txtValorFinal.getDouble();
        oProdutoCadastro.idSituacaoCadastro = cboSituacao.getId();
        oProdutoCadastro.foto = txtFoto.getText();

        if (cboSituacao.getId() == Situacao.ATIVO.getId()) {
            cboSituacao.setEnabled(false);
        }

        beanCadastro.salvarProduto(oProdutoCadastro);

        Util.exibirMensagem(Util.MSG_SALVO_SUCESSO, getTitle());

        txtCodigo.setInt(oProdutoCadastro.id);

        administrarPreco();

        getEstadoTelaInicial();
    }

    private void calculaValorBanhoMl(double pesoTotal) throws Exception {
        double valorml = 0;
        double precoGrama = 0;

        valorml = Global.getParametro(3).getInt() + Global.getParametro(4).getInt();
        precoGrama = ((valorml * Global.getParametro(5).getDouble()) / 1000);
        valorBanhoMl = pesoTotal * precoGrama;

    }

    private void administrarPreco() throws Exception {
        AdministracaoPrecoGUI form = new AdministracaoPrecoGUI(mdiFrame);

        form.setCampoId(txtCodigo.getInt());
        form.carregarCusto();
        form.setVisible(true);

    }

    private void alterarAcessorio() throws Exception {
        if (tblAcessorios.getLinhaSelecionada() == -1) {
            throw new LBException(Util.MSG_NENHUM_ITEM_SELECIONADO);
        }
        ProdutoCadastroItensGUI form = new ProdutoCadastroItensGUI(mdiFrame, this);
        form.carregarProduto(tblAcessorios.getLinhaSelecionada());
        form.setVisible(true);
    }

    private void removerAcessorio() throws Exception {
        if (tblAcessorios.getLinhaSelecionada() == -1) {
            throw new LBException(Util.MSG_NENHUM_ITEM_SELECIONADO);
        }

        Util.exibirMensagemConfirmar(Util.MSG_CONFIRMA_EXCLUSAO, getTitle());

        oProdutoCadastro.vItem.remove(tblAcessorios.getLinhaSelecionada());

        exibirAcessorio();

        tblAcessorios.requestFocus();
    }

    private void limparProduto() throws Exception {
        Util.exibirMensagemContinuar("Todos os produtos serão apagados!", getTitle());

        oProdutoCadastro.vItem = new Vector();

        exibirAcessorio();
    }

    public void copiarFoto(File src, File dst) throws IOException {
        InputStream in = new FileInputStream(src);
        OutputStream out = new FileOutputStream(dst);           // Transferindo bytes de entrada para saída
        byte[] buf = new byte[10000];
        int len;
        while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
        }
        in.close();
        out.close();
    }

    private void vRButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton1ActionPerformed

        try {
            adicionarAcessorio();

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_vRButton1ActionPerformed

    private void tblAcessoriosKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblAcessoriosKeyPressed
        try {
            if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                alterarAcessorio();

            } else if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
                removerAcessorio();
            }

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }
    }//GEN-LAST:event_tblAcessoriosKeyPressed

    private void tblAcessoriosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblAcessoriosMouseClicked

        try {
            if (evt.getClickCount() == 2) {
                alterarAcessorio();
            }

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_tblAcessoriosMouseClicked

    private void vRButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton2ActionPerformed
        try {
            removerAcessorio();

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }


    }//GEN-LAST:event_vRButton2ActionPerformed

    private void vRButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton3ActionPerformed

        try {
            this.setWaitCursor();
            limparProduto();

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());

        } finally {
            this.setDefaultCursor();
        }

    }//GEN-LAST:event_vRButton3ActionPerformed

    private void cboTipoProdutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboTipoProdutoActionPerformed
        double valorFinal = 0;
        double pesofinal = 0;

        try {
            if (cboTipoProduto.getId() == TipoProduto.BRINCO.getId() && isBrinco == false) {
                lblValorFinal.setText("Valor Custo Final do Par");
                valorFinal = txtValorFinal.getDouble() * 2;
                txtValorFinal.setDouble(valorFinal);
                txtPesoTotal.setDouble(pesoFinal * 2);
                txtValorBanho.setDouble(valorTotalBanho * 2);
                txtCustoTotal.setDouble(custoTotal * 2);
                isBrinco = true;
            }
            if (cboTipoProduto.getId() != TipoProduto.BRINCO.getId() && isBrinco == true) {
                lblValorFinal.setText("Valor Custo Final");
                precoTotal = precoTotal * 1;
                txtValorFinal.setDouble(precoTotal);
                pesofinal = pesoFinal;
                txtPesoTotal.setDouble(pesofinal);
                txtValorBanho.setDouble(valorTotalBanho);
                txtCustoTotal.setDouble(custoTotal);
                isBrinco = false;
            }
            
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        }
    }//GEN-LAST:event_cboTipoProdutoActionPerformed

    private void vRButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton4ActionPerformed
        try {
            verificarAlteracaoTela();
            sair();
            
        } catch (Exception e) {
        }
    }//GEN-LAST:event_vRButton4ActionPerformed

    private void vRButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton5ActionPerformed
        try {
            salvar();

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_vRButton5ActionPerformed

    private void vRButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton6ActionPerformed
        //****** Metodo para Selecionar a Foto com JFILE CHOOSER
        //****** Depende do método CopiaFoto ******

        try {
            JFileChooser busca_foto = new JFileChooser();
            busca_foto.setDialogTitle("Selecione a Imagem");

            //****************** FILTRO PRA BUSCAR SOMENTE JPG
            busca_foto.setFileFilter(new javax.swing.filechooser.FileFilter() {

                public boolean accept(File f) {
                    return (f.getName().endsWith(".jpg")) || f.isDirectory();
                }

                public String getDescription() {
                    return "*.JPG";
                }
            });
            busca_foto.setDialogTitle("Carregar imagem do acessorio");
            busca_foto.showOpenDialog(this);
            String foto = "" + busca_foto.getSelectedFile().getName();
            txtFoto.setText(foto);
            File arquivo = busca_foto.getSelectedFile();
            caminhoArquivo = arquivo.getCanonicalPath();

            //******************** Copia a Imagem para o Diretorio do Projeto ************
            File arquivo1 = new File(caminhoArquivo);
            File arquivo2 = new File("/LimeiraFol/Imagens/Produtos/" + txtFoto.getText());
            copiarFoto(arquivo1, arquivo2);
            lblFoto.setIcon(new ImageIcon("/LimeiraFol/Imagens/Produtos/" + txtFoto.getText()));

        } catch (Exception e) {
            //JOptionPane.showMessageDialog(null, "Não foi possivel carregar a foto");
        }
}//GEN-LAST:event_vRButton6ActionPerformed

    private void btnZoomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnZoomActionPerformed
        try {
            ProdutoCadastroFotoGUI form = new ProdutoCadastroFotoGUI(mdiFrame, this);
            form.setVisible(true);
            
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        }
    }//GEN-LAST:event_btnZoomActionPerformed

    private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosing
        try {
            verificarAlteracaoTela();
            sair();

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }
    }//GEN-LAST:event_formInternalFrameClosing

    private void adicionarAcessorio() throws Exception {

        ProdutoCadastroItensGUI form = new ProdutoCadastroItensGUI(mdiFrame, this);

        form.incluir();
        form.setVisible(true);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private lbframework.bean.button.LBButton btnZoom;
    private lbframework.bean.comboBox.LBComboBox cboSituacao;
    private lbframework.bean.comboBox.LBComboBox cboTipoBanho;
    private lbframework.bean.comboBox.LBComboBox cboTipoProduto;
    private javax.swing.JLabel lblFoto;
    private lbframework.bean.label.LBLabel lblPeso;
    private lbframework.bean.label.LBLabel lblValorFinal;
    private lbframework.bean.tableEx.LBTableEx tblAcessorios;
    private lbframework.bean.textField.LBTextField txtCodigo;
    private lbframework.bean.textField.LBTextField txtCodigoInterno;
    private lbframework.bean.textField.LBTextField txtCustoTotal;
    private lbframework.bean.textField.LBTextField txtDescricao;
    private lbframework.bean.textField.LBTextField txtFoto;
    private lbframework.bean.textField.LBTextField txtPesoTotal;
    private lbframework.bean.textField.LBTextField txtValorBanho;
    private lbframework.bean.textField.LBTextField txtValorFinal;
    private lbframework.bean.textField.LBTextField txtValorOuro;
    private lbframework.bean.button.LBButton vRButton1;
    private lbframework.bean.button.LBButton vRButton2;
    private lbframework.bean.button.LBButton vRButton3;
    private lbframework.bean.button.LBButton vRButton4;
    private lbframework.bean.button.LBButton vRButton5;
    private lbframework.bean.button.LBButton vRButton6;
    private lbframework.bean.label.LBLabel vRLabel1;
    private lbframework.bean.label.LBLabel vRLabel10;
    private lbframework.bean.label.LBLabel vRLabel11;
    private lbframework.bean.label.LBLabel vRLabel2;
    private lbframework.bean.label.LBLabel vRLabel3;
    private lbframework.bean.label.LBLabel vRLabel4;
    private lbframework.bean.label.LBLabel vRLabel5;
    private lbframework.bean.label.LBLabel vRLabel7;
    private lbframework.bean.label.LBLabel vRLabel8;
    private lbframework.bean.label.LBLabel vRLabel9;
    private lbframework.bean.panel.LBPanel vRPanel1;
    private lbframework.bean.panel.LBPanel vRPanel2;
    private lbframework.bean.panel.LBPanel vRPanel3;
    private lbframework.bean.panel.LBPanel vRPanel5;
    private lbframework.bean.toolBarPadrao.LBToolBarPadrao vRToolBarPadrao1;
    // End of variables declaration//GEN-END:variables
}
